#pragma once

#include "UMLCompartmentableShape.h"

#include "UMLCompartment.h"

namespace uml {

UMLCompartmentableShape::UMLCompartmentableShape(const QString& umlType)
    : UMLShape(umlType) {}

void UMLCompartmentableShape::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLShape::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(compartments_, "compartments", json, errorList);
}

void UMLCompartmentableShape::toJson(QJsonObject& json) {
    UMLShape::toJson(json);
    JsonSerializable::toJsonArray(compartments_, "compartments", json);
}

/// <summary>
/// compartments getter
/// Separated portions of the shape.
/// </summary>
vector<shared_ptr<UMLCompartment>>& UMLCompartmentableShape::compartments() {
    return compartments_;
}

} // namespace uml
